<template>
  <div class="player-container">
    <ArtPlayer :url="url" v-if="url" />
  </div>
</template>

<script setup>
import { onMounted, ref } from 'vue'
import ArtPlayer from './ArtPlayer.vue'
import { useRoute } from 'vue-router'
// import WebDavClient from '@/utils/webdav'
import API from '@/api'
import { createClient } from 'webdav/web'
// 创建一个新的 WebDAV 客户端实例
const WebDavClient = createClient('http://116.205.101.157:5244', {
  username: 'admin', // 用户名
  password: 'Wslmima.com123', // 密码
})
const route = useRoute()
const url = ref('')
onMounted(() => {
  if (route.query?.id) {
    const episode_id = route.query?.id
    API.getTvFiles(episode_id).then((res) => {
      // console.log('🚀 ~ API.getTvFiles ~ res:', res)
      const downloadLink = WebDavClient.getFileDownloadLink(res.path)
      console.log('downloadLink文件地址 >>>', downloadLink)
      url.value = downloadLink
    })
  }
})
</script>
<style lang="less" scoped>
.player-container {
  width: 100%;
  height: 100%;
}
</style>
